package refunds

import (
	"jlpay-sdk-go/pkg/jlpay/core"
	"jlpay-sdk-go/pkg/jlpay/models/trans/refunds"
	"jlpay-sdk-go/pkg/jlpay/services"
)

// RefundsService 退款申请服务
type RefundsService struct {
	*services.BaseService
}

// NewRefundsService 创建退款申请服务
func NewRefundsService(config *core.Config) *RefundsService {
	return &RefundsService{
		BaseService: services.NewBaseService(config),
	}
}

// Refunds 退款申请
func (s *RefundsService) Refunds(request *refunds.RefundsRequest) (*refunds.RefundsResponse, error) {
	response := refunds.NewRefundsResponse()
	err := s.Post(request, response, "/open/trans/refunds")
	if err != nil {
		return nil, err
	}
	return response, nil
}
